<?php
// header("Content-type:image/jpeg");
session_start();
$image = imagecreate(160, 80);
$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);
for($i=0;$i<12;$i++){
	imageline($image, rand(0,160), rand(0,80), rand(0,160), rand(0,80),$white);
}
for($i=0;$i<150;$i++){
	imagesetpixel($image, rand(0,160),rand(0,80), $white);
}
$str='';
for($i=0;$i<4;$i++){
	
	switch(rand(1,3)){
		case "1":
		$ch = rand(0,9);
		break;
		case "2":
		$ch = sprintf('%c',rand(97,122));
		break;
		case "3":
		$ch = sprintf("%c",rand(65,90));
		break;

	}
	$str.=$ch;
}
imagettftext($image, 30, rand(0,15), 10, 70, $white,"C:\Windows\Fonts\Arial.ttf",$str);
$_SESSION["str"]=$str;
// imagejpeg($image);
ob_start();
imagepng($image);
$fileContent = ob_get_contents();
ob_end_clean();
 
echo base64_encode($fileContent);
imagedestroy($image);

?>